import './css/adminlte.min.css';
import './css/app.css';


import { getLoginUserReq } from './api'
import { getToken, getUser, setUser } from "./utils/storageUtils";


(async function() {

    let href = window.location.href;

    let isLogin = href.includes('login');

    if (getToken()) {

        if (isLogin) {
            window.location.href = '/users.html'
        } else {

            if (!getUser()) {
                let user = await getLoginUserReq();

                setUser(user.data);
            }
        }

    } else {
        // 不存在token
        if (!isLogin) {
            window.location.href = '/login.html';
        }
    }

})()